import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import axios from 'axios'
import VueAxios from "vue-axios";

Vue.config.productionTip = false;
Vue.prototype.bus = new Vue(); //此处全局注册一个Vue作为事件中心,主要用作非父子组件间通信
Vue.use(VueAxios,axios);

new Vue({
	el: '#app',
	router,
	store,
  render: h => h(App),
}).$mount('#app');

// 表示可以在该项目的文件中用remote-script标签来应用js文件了
Vue.component('remote-script', {
    render: function (createElement) {
        var self = this;
        return createElement('script', {
            attrs: {
                type: 'text/javascript',
                src: this.src
            },
            on: {
                load: function (event) {
                    self.$emit('load', event);
                },
                error: function (event) {
                    self.$emit('error', event);
                },
                readystatechange: function (event) {
                    if (this.readyState == 'complete') {
                        self.$emit('load', event);
                    }
                }
            }
        });
    },

    props: {
        src: {
            type: String,
            required: true
        }
    }
});